package com.neuedu.week3Test3;

public class Rectangle extends Shape {
    /**
     * 矩形的宽
     */
    private double Width;
    /**
     * 矩形的高
     */
    private double height;

    /**
     * 空参构造
     */
    public Rectangle() {
    }

    /**
     * 全参构造
     * @param color 矩形的颜色
     * @param width 矩形的宽
     * @param height 矩形的高
     */
    public Rectangle(String color, double width, double height) {
        super(color);
        Width = width;
        this.height = height;
    }

    /**
     * get和set方法
     */
    public double getWidth() {
        return Width;
    }

    public void setWidth(double width) {
        Width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    /**
     * 重写父类的抽象方法
     * @return 矩形的面积
     */
    @Override
    public double getArea() {
        return this.height * this.Width;
    }

    /**
     *
     * @return 矩形的周长
     */
    @Override
    public double getPer() {
        return (this.height + this.Width) * 2;
    }

    @Override
    public void showAll() {
        System.out.println("矩形的宽为:" + this.Width);
        System.out.println("矩形的高为:" + this.height);
        System.out.println("矩形的颜色为" + this.getColor());
        System.out.println("面积为:" + getArea());
        System.out.println("周长为:" + getPer());
    }
}
